package com.yang.service;

import com.github.pagehelper.PageInfo;
import com.yang.mapper.UserMapper;
import com.yang.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.PageHelper;
import java.util.List;


public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public User login(User user) {
        return userMapper.login(user);
    }

    public PageInfo<User> queryByNameAndRole(User user, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userMapper.queryByNameAndRole(user);
        return new PageInfo<User>(list);
    }

    public Integer addUser(User user) {
        return userMapper.addUser(user);
    }

    public User queryById(Integer id) {
        return userMapper.queryById(id);
    }

    public Integer updateUser(User user) {
        return userMapper.updateUser(user);
    }

    public Integer deleteUser(Integer id) {
        return userMapper.deleteUser(id);
    }

    public Integer updateStatus(Integer id) {
        return userMapper.updateStatus(id);
    }

    public Integer updatePassword(User user) {
        return userMapper.updatePassword(user);
    }
}
